import java.util.Arrays;

/**
 * Created by L.jp
 * Description:
 * User: 86189
 * Date: 2022-05-29
 * Time: 23:01
 * @author 86189
 */
public class Main {
    public static void main ( String[] args ) {
        int[] arr={3,5,1,6,4,2,0};
        quickSort(arr,0,arr.length-1);
        System.out.println( Arrays.toString( arr ) );
    }
    private static void quickSort ( int[] arr , int start , int end ) {
        if(start>=end){
            return;
        }
        int left=start;
        int right=end;
        int pivot=arr[(left+right)/2];
        while (left <= right) {
            while ( left <= right && arr[left] < pivot ){
                left++;
            }
            while (left <= right && arr[right] > pivot) {
                right--;
            }
            if(left<=right){
                int tmp=arr[left];
                arr[left] = arr[right];
                arr[right] = tmp;
                left++;
                right--;
            }
        }
        quickSort( arr,start,right);
        quickSort( arr,left,end);
    }
}
